namespace MoreLinq.Test;

using System;
using System.Collections;
using System.Collections.Generic;

/// <summary>
/// Enumerable sequence which throws InvalidOperationException as soon as its
/// enumerator is requested. Used to check lazy evaluation.
/// </summary>
class BreakingSequence<T> : IEnumerable<T>
{
    public IEnumerator<T> GetEnumerator() => throw new BreakException();
    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}

sealed class BreakException : Exception
{
    public BreakException() { }
    public BreakException(string message) : base(message) { }
    public BreakException(string message, Exception inner) : base(message, inner) { }
}
